home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / docs.lha / latexinfo / elisp / german-fmt.el (.txt) < prev    next >
Encoding:
LaTeX Document  |  1992-02-21  |  6.2 KB  |  168 lines

  1. ;; LaTeXinfo support for European languages.
  2. (defun latexinfo-format-scan ()
  3.   ;; LaTeX sometimes uses \\ to force a new-line
  4.   (goto-char (point-min))
  5.   (replace-regexp "\\\\\\\\$" "")
  6.   ;; This is the same as latexinfo-format-scan, except for 
  7.   (goto-char (point-min))
  8.   (latexinfo-europe-doublequotes)
  9.   ;; And don't convert left and right quotes to typewriter font quotes.
  10.   ;;  (goto-char (point-min))
  11.   ;;  (while (search-forward "``" nil t)
  12.   ;;    (replace-match "\""))
  13.   ;;  (goto-char (point-min))
  14.   ;;  (while (search-forward "''" nil t)
  15.   ;;    (replace-match "\""))
  16.   ;; Scan for \-commands.
  17.   (goto-char (point-min))
  18.   (while (search-forward "\\" nil t)
  19.     (if (looking-at "[@{}'` *%]")
  20.     ;; Handle a few special \-followed-by-one-char commands.
  21.     (if (= (following-char) ?*)
  22.         ;; \* has no effect, since we are not filling.
  23.         (delete-region (1- (point)) (1+ (point)))
  24.       ;; The other characters are simply quoted.  Delete the \.
  25.       (delete-char -1)
  26.       (forward-char 1))
  27.       ;; \ is followed by a command-word; find the end of the word.
  28.       (setq latexinfo-command-start (1- (point)))
  29.       (if (= (char-syntax (following-char)) ?w)
  30.       (forward-word 1)
  31.     (forward-char 1))
  32.       (setq latexinfo-command-end (point))
  33.       ;; Call the handler for this command.
  34.       (setq latexinfo-command-name
  35.         (intern (buffer-substring (1+ latexinfo-command-start)
  36.                       latexinfo-command-end)))
  37.       (let ((cmd (get latexinfo-command-name 'latexinfo-format)))
  38.     (if cmd (funcall cmd)
  39.       (latexinfo-unsupported)))))
  40.   (cond (latexinfo-stack
  41.      (goto-char (nth 2 (car latexinfo-stack)))
  42.      (error "Unterminated \begin{%s}" (car (car latexinfo-stack))))))
  43. (defun latexinfo-europe-doublequotes ()
  44.   (while (search-forward "\"" nil t)
  45.     (forward-char -2)
  46.     (if (eq (following-char) ?\\)
  47.     ;; Ignore \"
  48.     (forward-char 2)
  49.       (progn
  50.     (forward-char 2)
  51.     (let ((next-char (following-char))
  52.           (here (point)))
  53.       (cond
  54.        ;; Just junk these cases:
  55.        ;; "| to separate ligatures.
  56.        ;; "- like \-, but allowing hyphenation in the rest of
  57.        ;;                    the word.
  58.        ;; "" like "-, but producing no hyphen sign.
  59.        ((memq next-char '(?\| ?\- ?\"))
  60.         (delete-region (- here 1) (+ here 1)))
  61.        ;; Just ignore these cases:
  62.        ;; "ck for ck to be hyphenated as k-k.
  63.        ;; "ff for ff to be hyphenated as ff-f, also for certain
  64.        ;;                    other consonants.
  65.        ((memq next-char '(?c ?f ?l ?m ?n ?p ?t ?C ?F ?L ?M ?N ?P ?T))
  66.         ;; There should be better testing here.
  67.         (delete-char -1))
  68.        ;; "a for Umlaut-a (like \"a), also for all other vowels.
  69.        ;; For these two, add an e.
  70.        ((memq next-char '(?a ?o ?u))
  71.         (delete-char -1)
  72.         (forward-char 1)
  73.         (insert "e"))
  74.        ((memq next-char '(?A ?O ?U))
  75.         (delete-char -1)
  76.         (forward-char 1)
  77.         (insert "E"))
  78.        ((memq next-char '(?e ?i ?E ?I))
  79.         (delete-char -1))
  80.        ;; s for sharp s  (like \ss{})
  81.        ((eq next-char ?s)
  82.         (delete-region (- here 1) (+ here 1))
  83.         (insert "ss"))
  84.        ;; ` or \glqq for german left  double quotes  (similar to ,,)
  85.        ((eq next-char ?\`)
  86.         (delete-region (- here 1) (+ here 1))
  87.         (insert "\\glqq "))
  88.        ;; ' or \grqq for german right double quotes  (similar to ``)
  89.        ((eq next-char ?\')
  90.         (delete-region (- here 1) (+ here 1))
  91.         (insert "\\grqq "))
  92.        ;; < or \flqq for french left  double quotes  (similar to <<)
  93.        ((eq next-char ?\<)
  94.         (delete-region (- here 1) (+ here 1))
  95.         (insert "\\flqq "))
  96.        ;; > or \frqq for french right double quotes  (similar to >>)
  97.        ((eq next-char ?\>)
  98.         (delete-region (- here 1) (+ here 1))
  99.         (insert "\\frqq "))
  100.        ;; Ignore all other cases
  101.        ))))
  102.     ))
  103. ;;; "` or \glqq        for german left  double quotes  (similar to ,,)
  104. (put 'glqq 'latexinfo-format 'latexinfo-format-glqq)
  105. (defun latexinfo-format-glqq ()
  106.   (latexinfo-parse-noarg)
  107.   (insert ",,"))
  108. ;;; "' or \grqq        for german right double quotes  (similar to ``)
  109. (put 'grqq 'latexinfo-format 'latexinfo-format-grqq)
  110. (defun latexinfo-format-grqq ()
  111.   (latexinfo-parse-noarg)
  112.   (insert "``"))
  113. ;;;       \glq         for german left  single quotes  (similar to , )
  114. (put 'glq 'latexinfo-format 'latexinfo-format-glq)
  115. (defun latexinfo-format-glq ()
  116.   (latexinfo-parse-noarg)
  117.   (insert ","))
  118. ;;;       \grq         for german right single quotes  (similar to ` )
  119. (put 'grq 'latexinfo-format 'latexinfo-format-grq)
  120. (defun latexinfo-format-grq ()
  121.   (latexinfo-parse-noarg)
  122.   (insert "`"))
  123. ;;; "< or \flqq        for french left  double quotes  (similar to <<)
  124. (put 'flqq 'latexinfo-format 'latexinfo-format-flqq)
  125. (defun latexinfo-format-flqq ()
  126.   (latexinfo-parse-noarg)
  127.   (insert "<<"))
  128. ;;; "> or \frqq        for french right double quotes  (similar to >>)
  129. (put 'frqq 'latexinfo-format 'latexinfo-format-frqq)
  130. (defun latexinfo-format-frqq ()
  131.   (latexinfo-parse-noarg)
  132.   (insert ">>"))
  133. ;;;       \flq         for french left  single quotes  (similar to < )
  134. (put 'flq 'latexinfo-format 'latexinfo-format-flq)
  135. (defun latexinfo-format-flq ()
  136.   (latexinfo-parse-noarg)
  137.   (insert "<"))
  138. ;;;       \frq         for french right single quotes  (similar to > )
  139. (put 'frq 'latexinfo-format 'latexinfo-format-frq)
  140. (defun latexinfo-format-frq ()
  141.   (latexinfo-parse-noarg)
  142.   (insert ">"))
  143. ;;; \ss
  144. (put 'ss 'latexinfo-format 'latexinfo-format-ss)
  145. (defun latexinfo-format-ss ()
  146.   (latexinfo-parse-noarg)
  147.   (insert "ss"))
  148. ;;; \dq                for the original quotes character (")
  149. (put 'dq 'latexinfo-format 'latexinfo-format-dq)
  150. (defun latexinfo-format-dq ()
  151.   (latexinfo-parse-noarg)
  152.   (insert "\""))
  153. ;;; \setlanguage{n}    to switch to the language specified by n
  154. (put 'setlanguage 'latexinfo-format 'latexinfo-format-noop)
  155. ;;; \originalTeX       to restore everything to the original settings
  156. (put 'originalTeX 'latexinfo-format 'latexinfo-format-originalTeX)
  157. ;; Unfortunately, this will not work yet in the info file.
  158. (defun latexinfo-format-originalTeX ()
  159.   (latexinfo-format-noop)
  160.   (setq latexinfo-germanTeX nil))
  161. ;;; \germanTeX         to re-activate the german settings.
  162. (put 'germanTeX 'latexinfo-format 'latexinfo-format-germanTeX)
  163. ;; Unfortunately, this is assumed throughout the info file.
  164. (defun latexinfo-format-germanTeX ()
  165.   (latexinfo-format-noop)
  166.   (setq latexinfo-germanTeX t))
  167. (setq latexinfo-germanTeX t)
  168.